package cn.tedu.service.impl;

import java.util.*;
import cn.tedu.service.*;
import cn.tedu.dao.DownloadDao;
import cn.tedu.entity.*;

public class DownloadServiceImpl implements DownloadService{

	DownloadDao dldao = new DownloadDao();
	public List<ClubDynamic> clist() {
		return dldao.clist();
	}

	public List<DataDownload> dlist() {
		return dldao.dlist();
	}

	public List<ClubResource> resList() {
		return dldao.resList();
	}

	/*
	 * @see cn.tedu.service.DownloadService#clist()
	 
	public List<ClubDynamic> clist() {
		Connection conn = DBUtil.getConnection();
		List<ClubDynamic> cList = new ArrayList<ClubDynamic>();
		try {
			String sql = "select * from downloadlist limit 1,8";
			PreparedStatement ps =  conn.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();
			while(rs.next()){
				ClubDynamic sd = new ClubDynamic();
				sd.setId(rs.getInt(1));
				sd.setTitle(rs.getString(2));
				sd.setIntroduce(rs.getString(3));
				sd.setCreateDate(rs.getDate(4));
				sd.setDownloadCount(rs.getInt(5));
				sd.setType(rs.getString(6));
				cList.add(sd);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return cList;
	}

	
	 * (non-Javadoc)
	 * @see cn.tedu.service.DownloadService#dlist()
	 
	public List<DataDownload> dlist() {
		Connection conn = DBUtil.getConnection();
		List<DataDownload> dList = new ArrayList<DataDownload>();
		try {
			String sql = "select * from downloadlist order by create_date desc limit 10,5";
			PreparedStatement ps =  conn.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();
			while(rs.next()){
				DataDownload dd = new DataDownload();
				dd.setId(rs.getInt(1));
				dd.setTitle(rs.getString(2));
				dd.setIntroduce(rs.getString(3));
				dd.setCreateDate(rs.getDate(4));
				dd.setDownloadCount(rs.getInt(5));
				dd.setType(rs.getString(6));
				dList.add(dd);
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return dList;
	}
	
	
	 * (non-Javadoc)
	 * @see cn.tedu.service.DownloadService#resList()
	 
	public List<ClubResource> resList() {
		Connection conn = DBUtil.getConnection();
		List<ClubResource> resList = new ArrayList<ClubResource>();
		try {
			String sql = "select * from club limit 15,4";
			PreparedStatement ps =  conn.prepareStatement(sql);
			ResultSet rs = ps.executeQuery();
			while(rs.next()){
				ClubResource cr = new ClubResource();
				cr.setId(rs.getInt(1));
				cr.setTitle(rs.getString(2));
				cr.setImgURL(rs.getString(4));
				cr.setIntroduce(rs.getString(3));
				resList.add(cr);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return resList;
	}*/
}
